package com.ruoyi.web.controller.restaurant;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.restaurant.domain.TbDinnerTable;
import com.ruoyi.restaurant.service.ITbDinnerTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐桌管理Controller
 * 
 * @author Wu
 * @date 2023-11-09
 */
@RestController
@RequestMapping("/restaurant/table")
public class TbDinnerTableController extends BaseController
{
    @Autowired
    private ITbDinnerTableService tbDinnerTableService;

    /**
     * 查询餐桌管理列表
     */
    @PreAuthorize("@ss.hasPermi('restaurant:table:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbDinnerTable tbDinnerTable)
    {
        startPage();
        List<TbDinnerTable> list = tbDinnerTableService.selectTbDinnerTableList(tbDinnerTable);
        return getDataTable(list);
    }

    /**
     * 导出餐桌管理列表
     */
    @PreAuthorize("@ss.hasPermi('restaurant:table:export')")
    @Log(title = "餐桌管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbDinnerTable tbDinnerTable)
    {
        List<TbDinnerTable> list = tbDinnerTableService.selectTbDinnerTableList(tbDinnerTable);
        ExcelUtil<TbDinnerTable> util = new ExcelUtil<TbDinnerTable>(TbDinnerTable.class);
        util.exportExcel(response, list, "餐桌管理数据");
    }

    /**
     * 获取餐桌管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('restaurant:table:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbDinnerTableService.selectTbDinnerTableById(id));
    }

    /**
     * 新增餐桌管理
     */
    @PreAuthorize("@ss.hasPermi('restaurant:table:add')")
    @Log(title = "餐桌管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbDinnerTable tbDinnerTable)
    {
        return toAjax(tbDinnerTableService.insertTbDinnerTable(tbDinnerTable));
    }

    /**
     * 修改餐桌管理
     */
    @PreAuthorize("@ss.hasPermi('restaurant:table:edit')")
    @Log(title = "餐桌管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbDinnerTable tbDinnerTable)
    {
        return toAjax(tbDinnerTableService.updateTbDinnerTable(tbDinnerTable));
    }

    /**
     * 删除餐桌管理
     */
    @PreAuthorize("@ss.hasPermi('restaurant:table:remove')")
    @Log(title = "餐桌管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbDinnerTableService.deleteTbDinnerTableByIds(ids));
    }
}
